test: fix flaky watch + cwd + argv test-runner test#64372
Open
pimterry wants to merge 1 commit into
Open
Conversation
Signed-off-by: Tim Perry <pimterry@gmail.com>
Member
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64372 +/- ##
==========================================
- Coverage 90.25% 90.25% -0.01%
==========================================
Files 741 741
Lines 241165 241192 +27
Branches 45428 45435 +7
==========================================
+ Hits 217667 217678 +11
- Misses 15069 15085 +16
Partials 8429 8429 🚀 New features to boost your workflow:
|
trivikr
approved these changes
Jul 8, 2026
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
MoLow
approved these changes
Jul 9, 2026
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the flaky test recently introduced in #63690.
I have seen #64084 which tried to fix this as well but was closed as it didn't reproduce under stress test on main, so it couldn't be verified.
I think that that PR's diagnosis is correct (writing in the watched folder causes the flake). This PR takes a slightly different approach: removing the 'marker' file write entirely, to verify on executed test names instead (dropping any possibility of races via IO or watch behaviour, by doing zero writes during the test).
I'm pretty sure I know the exact failure scenario:
test:passfires from the first inner run, passing themustCall(1)in the outer test.test:pass+test:watch:drainfiring (stopping all events and ending the test) vs the change event leading to a test re-run that firestest:passa 2nd time.test:watch:drainevent can easily be delayed unpredictably, since it's fired by the child process shutdown signal from the OS (plus a few other checks & async steps en route). >200ms delay between the write & the drain => flake.As noted there, this is hard to verify as flaky in the CI job, but it is verifiable with a manual delay:
test:watch:drainedif:test:pass).Dropping the IO solves this, since it guarantees no watch events will fire, and removes the race entirely. With this fix in place, it now passes 100% for me with the same or larger setTimeout delays added manually.
As a more general "prove a flake fix" argument, where it's difficult to repro, personally I think "repro with a manual delay in an unpredictable-duration step" is a reasonable demo, even if the stress test passes.